Skip to content

Add regression coverage for overloaded initializer Java names#781

Merged
ktoso merged 3 commits into
swiftlang:mainfrom
tiennguyen2310:fix-issue-425
Jun 10, 2026
Merged

Add regression coverage for overloaded initializer Java names#781
ktoso merged 3 commits into
swiftlang:mainfrom
tiennguyen2310:fix-issue-425

Conversation

@tiennguyen2310

Copy link
Copy Markdown
Contributor

Adds regression coverage for #425.
This covers the reported initializer-collision where distinct Swift initializers could otherwise produce duplicate Java init(...) signatures. The added tests assert that the generated FFM/JNI Java names are disambiguated, e.g. initThrowing and initDoInit, and that the raw duplicate init(...) signatures are absent.

Closes #425.

Test:

  • swift test --filter MethodImportTests

@tiennguyen2310 tiennguyen2310 requested a review from ktoso as a code owner June 8, 2026 10:10
public init(throwing: Swift.Bool) throws
public init(doInit: Swift.Bool)
}
"""

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No real reason for two separate input strings

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yub, I have consolidated into 1 shared input.

"public static OverloadedInitializerClass init(boolean throwing, SwiftArena swiftArena)",
"public static java.util.Optional<OverloadedInitializerClass> init(boolean doInit, SwiftArena swiftArena)",
]
)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make it one test that is parameterized over the two modes please

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated, thanks! I merged into 1 parameterized test over JNI/FFM.

@ktoso

ktoso commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

Thanks :)

@ktoso ktoso merged commit 8aad98a into swiftlang:main Jun 10, 2026
41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[jextract] Handle ambiguous Swift methods not possible in Java

2 participants